package ltd.hanamaki.review.basic;

import java.util.Arrays;

/**
 * @Author Hanamaki
 * @Version 1.0
 */
public class TwoSum {

    public static void main(String[] args) {

        int a[] = {2, 7, 11, 15};
        int target = 9;

        int[] ints = new TwoSum().twoSum(a, target);
        System.out.println(Arrays.toString(ints));


    }

    public int[] twoSum(int[] nums, int target) {
        int result[] = new int[2];
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (target == nums[i] + nums[j]) {
                    result[0] = i;
                    result[1] = j;
                }
            }
        }
        return result;
    }


}